|
|
 |
|
|
|
|
'************************************************************
'* Procedure: FormCenter() - Center Form on the Screen
'* Author : Paul D. Sheriff
'* Date : Oct. 22, 1998
'* Revised : Oct. 22, 1998
'*
'* Description:
'* Center Form on the Screen or MDI Main Form
'*
'* Syntax: Call FormCenter(frmFormName)
'*
'* Parameters:
'* <frm> frmFormName => Form To Center
'************************************************************
Sub FormCenter (frmFormName As Form)
frmFormName.Left = (Screen.Width - frmFormName.Width) / 2
frmFormName.Top = (Screen.Height - frmFormName.Height) / 2
End Sub |
|
|
|
|
|
|
|
|
Always use the & operator when concatenating strings and the + operator when working with numerical values. Using + may cause problems when operating on two variants. Heres an example: |
|
|
|
 |
|
|
|
|
vntVar1="10.01"
vntVar2 = 11
vntResult = vntVar1 + vntVar2 ' vntResult = 21.01
vntResult = vntVar1 & vntVar2 ' vntResult = 10.0111 |
|
|
|
|
|
|
|
|
As you can see from this source code, the + and & operators create two different results when using the Variant data type. This is a good reason to always use the appropriate operator and avoid using a Variant data type. |
|
|
|
|
|
|
|
|
Variables should always be defined with the smallest scope possible. Global variables can create enormously complex state machines and make the logic of an application extremely difficult to understand. Global variables also make the reuse and maintenance of your code much more difficult. Variables in Visual Basic can have the following scope, as detailed in Table A.9. |
|
|
|
|
|